package com.test.client.customTimeLine;

import java.util.ArrayList;

import com.google.gwt.user.client.Window;
import com.netthreads.gwt.simile.timeline.client.DateTime;
import com.netthreads.gwt.simile.timeline.client.Theme;

public class TimelineRenderer implements ITimeLineRender {
	public void render(TimeLineWidget widget) {

		int x = Window.getClientWidth();
		int y = Window.getClientWidth() / 7;
		int width = x - y;
		//widget.setPixelSize(width, 100);
		widget.setHeight("100px");
		widget.setWidth("100%");
		ArrayList<BandInfo> bandInfos = widget.getBandInfos();
		ArrayList<ZoomStepOptions> zoomSteps = new ArrayList<ZoomStepOptions>();

		EventSource eventSource = widget.getEventSource();

		Theme theme = widget.getTheme();
		theme.setEventLabelWidth(400);

		ZoomStepOptions zoomStepOption;
		zoomStepOption = ZoomStepOptions.create();
		zoomStepOption.setUnit(DateTime.DAY());
		zoomStepOption.setPixelsPerInterval(400);
		zoomSteps.add(zoomStepOption);

		zoomStepOption = ZoomStepOptions.create();
		zoomStepOption.setUnit(DateTime.DAY());
		zoomStepOption.setPixelsPerInterval(300);
		zoomSteps.add(zoomStepOption);
		zoomStepOption = ZoomStepOptions.create();
		zoomStepOption.setUnit(DateTime.DAY());
		zoomStepOption.setPixelsPerInterval(200);
		zoomSteps.add(zoomStepOption);
		zoomStepOption = ZoomStepOptions.create();
		zoomStepOption.setUnit(DateTime.DAY());
		zoomStepOption.setPixelsPerInterval(100);
		zoomSteps.add(zoomStepOption);
		zoomStepOption = ZoomStepOptions.create();
		zoomStepOption.setUnit(DateTime.DAY());
		zoomStepOption.setPixelsPerInterval(50);
		zoomSteps.add(zoomStepOption);

		zoomStepOption = ZoomStepOptions.create();
		zoomStepOption.setUnit(DateTime.DAY());
		zoomStepOption.setPixelsPerInterval(25);
		zoomSteps.add(zoomStepOption);

		zoomSteps.add(zoomStepOption);

		BandOptions bottomOpts = BandOptions.create();
		bottomOpts.setWidth("100%");
		bottomOpts.setDate("06/09/2010");
		bottomOpts.setTrackHeight(1.3f);

		bottomOpts.setTrackGap(0.1f);
		bottomOpts.setIntervalUnit(DateTime.MONTH());
		bottomOpts.setIntervalPixels(150);

		bottomOpts.setShowEventText(true);
		bottomOpts.setTheme(theme);
		bottomOpts.setEventSource(eventSource);
		bottomOpts.setZoomIndex(10);
		bottomOpts.setZoomSteps(zoomSteps);
		bottomOpts.setTimeZone(0);
		BandInfo bottom = BandInfo.create(bottomOpts);

		bandInfos.add(bottom);

	}

}
